<template>
  <div class="billedit">
    <van-row>
      <van-col span="12">
        <van-button plain type="info">拍照识别</van-button>
      </van-col>
      <van-col span="12">
        <van-button plain type="info">扫码识别</van-button>
      </van-col>
    </van-row>
    <van-form @submit="onSubmit">
      <van-field
        v-model="amount"
        name="金额"
        label="金额"
        placeholder="请输入金额"
        :rules="[{ required: true, message: '请填写金额' }]"
      />
      <van-field
        v-model="billitems"
        name="项目"
        label="项目"
        placeholder="请输入项目"
        :rules="[{ required: true, message: '请填写项目名' }]"
      >
      </van-field>
      <van-field
        v-model="explain"
        name="说明"
        label="说明"
        placeholder="请输入费用说明"
        :rules="[{ required: true, message: '请填写费用说明' }]"
      />
      <van-row>
        <van-col span="24">
          <van-field name="uploader">
            <template #input>
              <van-uploader v-model="uploader" />
            </template>
          </van-field>
        </van-col>
      </van-row>
      <div class="editbtn">
        <van-button type="danger" router-link to="/" >取消</van-button>
        <van-button type="primary" native-type="submit">保存</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import { Dialog } from 'vant';

export default {
  name: 'BillEdit',

  data() {
    return {
      amount: '',
      billitems: '',
      explain: '',

      uploader: [{ url: 'https://img.yzcdn.cn/vant/leaf.jpg' }],
      list: [
        { name: '门诊挂号费', money: '120.00' },
        { name: '检查费', money: '88.88' },
        { name: '中药费', money: '10.99' },
      ],
      money: {},
      result: [],
    };
  },
  methods: {
    toggle(index) {
      this.$refs.checkboxes[index].toggle();
    },
    onSubmit(values) {
      function beforeClose(action, done) {
        if (action === 'confirm') {
          console.log('submit', values);
          setTimeout(done, 1000);
        } else {
          done();
        }
      }
      Dialog.confirm({
        title: '标题',
        message: '弹窗内容',
        beforeClose,
      }).then(() => {
        this.$router.push('/');
      });
    },
  },
};
</script>

<style scoped>

</style>
